#include "ThreadPool.hpp"
#include "Task.hpp"
#include <unistd.h>
#include <ctime>

int main()
{
    srand(time(nullptr) ^ getpid());
    ThreadPool<Task> *tp = new ThreadPool<Task>();
    tp->start();

    while (true)
    {
        int len = op.size();
        // 派发任务
        int data1 = rand() % 10 + 1;
        usleep(10);
        int data2 = rand() % 10;
        char oper = op[rand() % len];

        Task t(data1, data2, oper);

        tp->push(t);

        std::cout << "thread done task : " << t.GetTask() << std::endl;
        sleep(1);

        // 线程处理
        std::cout << "thread is running" << std::endl;
    }

    return 0;

}